<?php require_once('connections/con_gl.php');  ?>

<?php

//cekAkses($_SESSION[akses],"A-1","A-1-2");

$colname_edit = "-1";

if (isset($_GET['id'])) {

  $colname_edit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);

}

mysql_select_db($database_con_gl, $con_gl);

$query_edit = sprintf("SELECT * FROM gl_admin WHERE id = %s", $colname_edit);

$edit = mysql_query($query_edit, $con_gl) or die(mysql_error());

$row_edit = mysql_fetch_assoc($edit);

$totalRows_edit = mysql_num_rows($edit);



mysql_select_db($database_con_gl, $con_gl);

$query_kary = "SELECT id, nama FROM gl_kontak ORDER BY nama ASC";

$kary = mysql_query($query_kary, $con_gl) or die(mysql_error());

$row_kary = mysql_fetch_assoc($kary);

$totalRows_kary = mysql_num_rows($kary);

?>

<script type="text/javascript" src="js/jquery.wysiwyg.js"></script>

<script type="text/javascript">

$(document).ready(function() {



	$().ajaxStart(function() {

		$('#loading').show();

		$('#result').hide();

	}).ajaxStop(function() {

		$('#loading').hide();

		$('#result').fadeIn('slow');

	});



	$('#edit').submit(function() {

		$.ajax({

			type: 'POST',

			url: $(this).attr('action'),

			data: $(this).serialize(),

			success: function(data) {

				$('#result').html(data);

			}

		})

		return false;

	});

  $('#result').click(function(){

  $(this).hide();

  });

})

$(function()

  {

      $('#alamat').wysiwyg();

	  $('#b_alamat').wysiwyg();

  });

</script>

<link type="text/css" rel="stylesheet" href="css/jquery.wysiwyg.css" />

<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>

<div id="result" style="display:none;"></div>

<h1>Edit User</h1>

<form action="proses/user.php?act=edit" method="POST" name="edit" id="edit">

  <table width="95%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF" class="datatable">

    <tr>

      <td width="19%" align="right">Username : </td>

      <td width="81%"><label>

        <input name="username" type="text" id="username" value="<?php echo $row_edit['username']; ?>" size="20" maxlength="20" />

      </label></td>
    </tr>

    <tr>

      <td align="right">Password : </td>

      <td><label>

        <input name="password" type="password" id="password" value="<?php echo simple_decrypt($row_edit['password']) ?>" size="20" maxlength="20" />

      </label></td>
    </tr>

    <tr>

      <td align="right">Link Karyawan : </td>

      <td><label>

        <select name="karyawan" id="karyawan">

          <option value="0" <?php if (!(strcmp(0, $row_edit['link']))) {echo "selected=\"selected\"";} ?>>Not Set</option>

          <?php

do {  

?>

          <option value="<?php echo $row_kary['id']?>"<?php if (!(strcmp($row_kary['id'], $row_edit['link']))) {echo "selected=\"selected\"";} ?>><?php echo $row_kary['nama']?></option>

          <?php

} while ($row_kary = mysql_fetch_assoc($kary));

  $rows = mysql_num_rows($kary);

  if($rows > 0) {

      mysql_data_seek($kary, 0);

	  $row_kary = mysql_fetch_assoc($kary);

  }

?>
        </select>

      </label></td>
    </tr>

    <tr valign="top">

      <td align="right">Pengaturan :</td>

      <td><table width="100%" border="0" cellspacing="1" cellpadding="2" class="datatable">

        <tr>

          <th width="22%">User</th>

          <th width="20%">Jenis Document</th>

          <th width="20%">Status Document</th>

          <th width="22%">Document</th>
          <th width="20%">Laporan</th>
          </tr>

        <tr valign="top">

          <td><ul style="list-style:none;">
            
            <li>
              
              <label>
                
                <input name="user_1" type="checkbox" id="user_1" value="A-1-1" <?php if(strstr($row_edit['akses'],"A-1-1")) { ?>checked="checked"<?php } ?>/>
                
                Tambah Data</label>
              </li>
            
            <li>
              
              <label>
                
                <input name="user_2" type="checkbox" id="user_2" value="A-1-2" <?php if(strstr($row_edit['akses'],"A-1-2")) { ?>checked="checked"<?php } ?>/>
                
                Edit Data</label>
              </li>
            
            <li>
              
              <label>
                
                <input name="user_3" type="checkbox" id="user_3" value="A-1-3" <?php if(strstr($row_edit['akses'],"A-1-3")) { ?>checked="checked"<?php }?>/>
                
                Hapus Data</label>
              </li>
            
            <li>
              
              <label>
                
                 <input name="user_4" type="checkbox" id="user_4" value="AUSER" <?php if(strstr($row_edit['akses'],"AUSER")) { ?>checked="checked"<?php }?>/>
                
                Lihat Data</label>
              </li>
            
            <li>
              
              <label>
                
                <input name="user_5" type="checkbox" id="user_5" value="A-1-4" <?php if(strstr($row_edit['akses'],"A-1-4")) { ?>checked="checked"<?php } ?>/>
                
                Super User</label></li>
            
          </ul></td>
          <td><ul style="list-style:none;">
            <li>
              <label>
                <input name="jenisdok_1" type="checkbox" id="jenisdok_1" value="A-2-1" <?php if(strstr($row_edit['akses'],"A-2-1")) { ?>checked="checked"<?php } ?>/>
                Tambah Data</label>
              </li>
            <li>
              <label>
                <input name="jenisdok_2" type="checkbox" id="jenisdok_2" value="A-2-2" <?php if(strstr($row_edit['akses'],"A-2-2")) { ?>checked="checked"<?php } ?>/>
                Edit Data</label>
              </li>
            <li>
              <label>
                <input name="jenisdok_3" type="checkbox" id="jenisdok_3" value="A-2-3" <?php if(strstr($row_edit['akses'],"A-2-3")) { ?>checked="checked"<?php } ?>/>
                Hapus Data</label>
              </li>
            <li>
              <label>
                <input name="jenisdok_4" type="checkbox" id="jenisdok_4" value="A-2" <?php if(strstr($row_edit['akses'],"A-2")) { ?>checked="checked"<?php } ?>/>
                Lihat Data</label>
              </li>
          </ul></td>
          <td><ul style="list-style:none;">
            <li>
              <label>
                <input name="statusdok_1" type="checkbox" id="statusdok_1" value="A-3-1" <?php if(strstr($row_edit['akses'],"A-3-1")) { ?>checked="checked"<?php } ?>/>
                Tambah Data</label>
              </li>
            <li>
              <label>
                <input name="statusdok_2" type="checkbox" id="statusdok_2" value="A-3-2"  <?php if(strstr($row_edit['akses'],"A-3-2")) { ?>checked="checked"<?php } ?>/>
                Edit Data</label>
              </li>
            <li>
              <label>
                <input name="statusdok_3" type="checkbox" id="statusdok_3" value="A-3-3" <?php if(strstr($row_edit['akses'],"A-3-3")) { ?>checked="checked"<?php } ?>/>
                Hapus Data</label>
              </li>
            <li>
              <label>
                <input name="statusdok_4" type="checkbox" id="statusdok_4" value="A-3" <?php if(strstr($row_edit['akses'],"A-3")) { ?>checked="checked"<?php } ?>/>
                Lihat Data</label>
              </li>
          </ul></td>
          <td><ul style="list-style:none;">
            <li>
              <label>
                <input name="dokumen_1" type="checkbox" id="dokumen_1" value="A-4-1" <?php if(strstr($row_edit['akses'],"A-4-1")) { ?>checked="checked"<?php } ?>/>
                Tambah Data</label>
              </li>
            <li>
              <label>
                <input name="dokumen_2" type="checkbox" id="dokumen_2" value="A-4-2" <?php if(strstr($row_edit['akses'],"A-4-2")) { ?>checked="checked"<?php } ?>/>
                Edit Data</label>
              </li>
            <li>
              <label>
                <input name="dokumen_3" type="checkbox" id="dokumen_3" value="A-4-3" <?php if(strstr($row_edit['akses'],"A-4-3")) { ?>checked="checked"<?php } ?>/>
                Hapus Data</label>
              </li>
            <li>
              <label>
                <input name="dokumen_4" type="checkbox" id="dokumen_4" value="A-4" <?php if(strstr($row_edit['akses'],"A-4")) { ?>checked="checked"<?php } ?>/>
                Lihat Data</label>
              </li>
            <li>
              <label>
                <input name="dokumen_5" type="checkbox" id="dokumen_5" value="distribusi" <?php if(strstr($row_edit['akses'],"distribusi")) { ?>checked="checked"<?php } ?>/>
                Distribusi Data</label>
            </li>
          </ul></td>
          <td><ul style="list-style:none;">
            <li>
              <input name="dokumen_6" type="checkbox" id="dokumen_6" value="A-5" <?php if(strstr($row_edit['akses'],"A-4")) { ?>checked="checked"<?php } ?>/>
            </li>
          </ul></td>
          </tr>

      </table>        <table width="100%" border="0" cellspacing="1" cellpadding="2" class="datatable">
          <tr>
            <th width="21%">Kontak</th>
            <th width="19%">Unit Kerja</th>
            <th width="19%">Unit Bisnis</th>
            <th width="21%">Karyawan</th>
            <th width="20%">Info Perusahaan </th>
          </tr>
          <tr valign="top">
            <td><ul style="list-style:none;">
              <li>
                <label>
                  <input name="kontak_1" type="checkbox" id="kontak_1" value="B-1-1" <?php if(strstr($row_edit['akses'],"B-1-1")) { ?>checked="checked"<?php } ?>/>
                  Tambah Data</label>
              </li>
              <li>
                <label>
                  <input name="kontak_2" type="checkbox" id="kontak_2" value="B-1-2" <?php if(strstr($row_edit['akses'],"B-1-2")) { ?>checked="checked"<?php } ?>/>
                  Edit Data</label>
              </li>
              <li>
                <label>
                  <input name="kontak_3" type="checkbox" id="kontak_3" value="B-1-3" <?php if(strstr($row_edit['akses'],"B-1-3")) { ?>checked="checked"<?php } ?>/>
                  Hapus Data</label>
              </li>
              <li>
                <label>
                  <input name="kontak_4" type="checkbox" id="kontak_4" value="B-1" <?php if(strstr($row_edit['akses'],"B-1")) { ?>checked="checked"<?php } ?>/>
                  Lihat Data</label>
              </li>
            </ul></td>
            <td><ul style="list-style:none;">
              <li>
                <label>
                  <input name="unitkerja_1" type="checkbox" id="unitkerja_1" value="B-2-1" <?php if(strstr($row_edit['akses'],"B-2-1")) { ?>checked="checked"<?php } ?>/>
                  Tambah Data</label>
              </li>
              <li>
                <label>
                  <input name="unitkerja_2" type="checkbox" id="unitkerja_2" value="B-2-2" <?php if(strstr($row_edit['akses'],"B-2-2")) { ?>checked="checked"<?php } ?>/>
                  Edit Data</label>
              </li>
              <li>
                <label>
                  <input name="unitkerja_3" type="checkbox" id="unitkerja_3" value="B-2-3" <?php if(strstr($row_edit['akses'],"B-2-3")) { ?>checked="checked"<?php } ?>/>
                  Hapus Data</label>
              </li>
              <li>
                <label>
                  <input name="unitkerja_4" type="checkbox" id="unitkerja_4" value="B-2" <?php if(strstr($row_edit['akses'],"B-2")) { ?>checked="checked"<?php } ?>/>
                  Lihat Data</label>
              </li>
            </ul></td>
            <td><ul style="list-style:none;">
              <li>
                <label>
                  <input name="unitbisnis_1" type="checkbox" id="service_9" value="B-3-1" <?php if(strstr($row_edit['akses'],"B-3-1")) { ?>checked="checked"<?php } ?>/>
                  Tambah Data</label>
              </li>
              <li>
                <label>
                  <input name="unitbisnis_2" type="checkbox" id="service_10" value="B-3-2" <?php if(strstr($row_edit['akses'],"B-3-2")) { ?>checked="checked"<?php } ?>/>
                  Edit Data</label>
              </li>
              <li>
                <label>
                  <input name="unitbisnis_3" type="checkbox" id="service_11" value="B-3-3" <?php if(strstr($row_edit['akses'],"B-3-3")) { ?>checked="checked"<?php } ?>/>
                  Hapus Data</label>
              </li>
              <li>
                <label>
                  <input name="unitbisnis_4" type="checkbox" id="service_12" value="B-3" <?php if(strstr($row_edit['akses'],"B-3")) { ?>checked="checked"<?php } ?>/>
                  Lihat Data</label>
              </li>
            </ul></td>
            <td><ul style="list-style:none;">
              <li>
                <label>
                  <input name="karyawan_1" type="checkbox" id="karyawan_1" value="B-4-1" <?php if(strstr($row_edit['akses'],"B-4-1")) { ?>checked="checked"<?php } ?>/>
                  Tambah Data</label>
              </li>
              <li>
                <label>
                  <input name="karyawan_2" type="checkbox" id="karyawan_2" value="B-4-2" <?php if(strstr($row_edit['akses'],"B-4-2")) { ?>checked="checked"<?php } ?>/>
                  Edit Data</label>
              </li>
              <li>
                <label>
                  <input name="karyawan_3" type="checkbox" id="karyawan_3" value="B-4-3" <?php if(strstr($row_edit['akses'],"B-4-3")) { ?>checked="checked"<?php } ?>/>
                  Hapus Data</label>
              </li>
              <li>
                <label>
                  <input name="karyawan_4" type="checkbox" id="karyawan_4" value="B-4" <?php if(strstr($row_edit['akses'],"B-4")) { ?>checked="checked"<?php } ?>/>
                  Lihat Data</label>
              </li>
            </ul></td>
            <td><ul style="list-style:none;">
              <li>
                <label>
                  <input name="infoper_1" type="checkbox" id="infoper_1" value="B-5-1" <?php if(strstr($row_edit['akses'],"B-5-1")) { ?>checked="checked"<?php } ?>/>
                  Tambah Data</label>
              </li>
              <li>
                <label>
                  <input name="infoper_2" type="checkbox" id="infoper_2" value="B-5-2" <?php if(strstr($row_edit['akses'],"B-5-2")) { ?>checked="checked"<?php } ?>/>
                  Edit Data</label>
              </li>
              <li>
                <label>
                  <input name="infoper_3" type="checkbox" id="infoper_3" value="B-5-3" <?php if(strstr($row_edit['akses'],"B-5-3")) { ?>checked="checked"<?php } ?>/>
                  Hapus Data</label>
              </li>
              <li>
                <label>
                  <input name="infoper_4" type="checkbox" id="infoper_4" value="B-5" <?php if(strstr($row_edit['akses'],"B-5")) { ?>checked="checked"<?php } ?>/>
                </label>
                Lihat Data</li>
            </ul></td>
          </tr>
              </table></td>
    </tr>

    <tr>

      <td align="left">

      <em>*Harus diisi</em>

      <input name="id" type="hidden" id="id" value="<?php echo $row_edit['id']; ?>" /></td>

      <td><label><input name="Save" type="submit" id="Save" value="Simpan" /></label> <label><input type="button" name="Button" value="Batal" onClick="javascript:history.go(-1);"></label></td>
    </tr>
  </table>

  

  <input type="hidden" name="MM_update" value="add">

</form>